
// validTime = function () {
//     var time = timeFormat("yyyyMMdd");
//     if (parseInt(time) > 20220814) {
//         toast("该续费了");
//         exit();
//     }
// };

// validTime();

/**
 *
 * @param new_validFile_ui_other
 */
eye_valid = function (new_validFile_ui_other) {
    var text = device.getModel() + "-" +
        device.getBrand() + "-" +
        device.getScreenHeight() + "-" +
        device.getScreenWidth();
    var two = utils.dataMd5(text).substring(0, 16).toUpperCase();
    if (file.exists(new_validFile_ui_other)) {
        var txt = file.readLine(new_validFile_ui_other, 1);
        if (txt.split("BSB")[1] === two) {
            var url = "https://gitee.com/baishui0212/redbook/raw/master/eyeValid/" + txt;
            var data = http.httpGetDefault(url, 5 * 1000);
            if (data.toLowerCase().indexOf("ok") === -1) {
                loge("远程注册设备失败，请联系管理员");
                exit();
            } else {
                var array = data.split("#");
                if(array.length === 2){
                    var endTime = array[1];
                    if(endTime === ""){
                        loge("你没有续费... 拜拜啦~");
                        exit();
                    }
                    var nowTime = timeFormat("yyyyMMdd");
                    if (nowTime > endTime) {
                        loge("{} 到期啦，你该续费啦...", endTime);
                        exit();
                    }
                }
            }
        } else {
            logd("bad gay! out");
            exit();
        }
    } else {
        logd("bad gay! out!");
        loge("远程注册设备失败，请联系管理员");
        exit();
    }
};

valid = function () {
    var new_validFile = "/sdcard/eyes/other.txt";
    loge("远程注册设备...");
    eye_valid(new_validFile);
};

valid();